﻿<Window x:Class="SenenFernandez.SmartImageComparer.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:SenenFernandez.SmartImageComparer.Properties"
        xmlns:ViewModel="clr-namespace:SenenFernandez.SmartImageComparer"
        Style="{StaticResource TransparentWindow}"
        WindowStartupLocation="CenterScreen"
        MinWidth="400" MinHeight="250"
        MaxWidth="800" MaxHeight="400"
        Name="MainWindow"
        FocusManager.FocusedElement="{Binding ElementName=ImagePathText}">
    <Window.DataContext>
        <ViewModel:MainViewModel />
    </Window.DataContext>
    <DockPanel IsEnabled="{Binding IsReadyToWork}">
        <Border Style="{StaticResource HeaderBorder}">
            <Border.InputBindings>
                <MouseBinding Command="{Binding DragWindowCommand}"
                              CommandParameter="{Binding ElementName=MainWindow}"
                              Gesture="LeftClick" />
            </Border.InputBindings>
            <DockPanel>
                <Button Style="{StaticResource CloseButton}" Command="{Binding CloseCommand}"
                        CommandParameter="{Binding ElementName=MainWindow}" />
                <Label Style="{StaticResource WindowTitle}" />
            </DockPanel>
        </Border>
        <Border DockPanel.Dock="Top">
            <DockPanel>
                <Button DockPanel.Dock="Right" Content="{x:Static p:Resources.Compare}" Command="{Binding CompareCommand}" />
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Label Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.OriginalImagePath}" />
                    <TextBox Grid.Row="0" Grid.Column="1" Name="ImagePathText" Text="{Binding ImagePath}" />
                    <Button Grid.Row="0" Grid.Column="2" DockPanel.Dock="Right" Content="{x:Static p:Resources.Browse}" Command="{Binding SelectImageCommand}" />
                    <Label Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.SearchDirectoryPath}" />
                    <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SearchDirectory}" />
                    <Button Grid.Row="1" Grid.Column="2" DockPanel.Dock="Right" Content="{x:Static p:Resources.Browse}" Command="{Binding SelectDirectoryCommand}" />
                </Grid>
            </DockPanel>
        </Border>
        <ProgressBar DockPanel.Dock="Bottom" Value="{Binding CurrentProgress}"
                     Visibility="{Binding IsReadyToWork, Converter={StaticResource BoolToVisibilityInvertConverter}}"/>
        <Border DockPanel.Dock="Bottom"
                Visibility="{Binding Duplicates.Count, Converter={StaticResource BoolToVisibilityConverter}}">
            <ListBox ItemsSource="{Binding Duplicates}" MaxHeight="200" SelectionMode="Multiple">
                <ListBox.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="{x:Static p:Resources.Copy}"
                                  Command="{Binding CopyCommand}"
                                  CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}" />
                    </ContextMenu>
                </ListBox.ContextMenu>
            </ListBox>
        </Border>
        <Border DockPanel.Dock="Right" Width="100" Height="100">
            <Image Source="{Binding SearchImage}" />
        </Border>
        <Border>
            <Image Source="{Binding OriginalImage}" />
        </Border>
    </DockPanel>
</Window>